{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" action="{:U('Role/add')}" method="post" class="form-horizontal">
        <div class="form-group row">
            <label class="form-control-label col-md-2">角色名称：</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="name">
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">角色状态：</label>
            <div class="col-md-5">
                <label class="radio-inline"><input type="radio" class="radio" value="1" name="status" checked="">启用</label>
                <label class="radio-inline"><input type="radio" class="radio" value="0" name="status">关闭</label>
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">备注说明：</label>
            <div class="col-md-5">
                <input type="text" name="remark" class="form-control" value="{$info.remark}">
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>

    </form>
</div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });
            } else {
                layer.msg(data.info, {
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }
    </script>

    {/block}